package com.rusefi.maintenance.migration.table_add_columns_migration;

import com.opensr5.ini.field.ArrayIniField;
import com.rusefi.config.FieldType;
import com.rusefi.maintenance.TestTuneMigrationContext;
import com.rusefi.maintenance.migration.migrators.ComposedTuneMigrator;
import com.rusefi.tune.xml.Constant;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import javax.xml.bind.JAXBException;

import java.util.Map;

import static com.rusefi.maintenance.migration.migrators.TableAddColumnsMigrator.*;
import static org.junit.jupiter.api.Assertions.*;

public class TableAddColumnsMigratorTest {
    private TestTuneMigrationContext testContext;

    @BeforeEach
    void setUp() throws JAXBException {
        testContext = TestTuneMigrationContext.load(
            "src/test/java/com/rusefi/maintenance/migration/table_add_columns_migration/test_data"
        );
        ComposedTuneMigrator.INSTANCE.migrateTune(testContext);

        final Map<String, Constant> migratedConstants = testContext.getMigratedConstants();
        assertEquals(8, migratedConstants.size());
    }

    @Test
    void checkVeTableMigration() {
        testContext.checkPrevAndUpdatedIniFields(
            VE_TABLE_FIELD_NAME,
            new ArrayIniField(
                VE_TABLE_FIELD_NAME,
                31636,
                FieldType.UINT16,
                16,
                16,
                "%",
                0.1,
                "0",
                "999",
                "1"
            ),
            new ArrayIniField(
                VE_TABLE_FIELD_NAME,
                31636,
                FieldType.UINT16,
                24,
                16,
                "%",
                0.1,
                "0",
                "999",
                "1"
            )
        );

        testContext.checkValueMigration(
            VE_TABLE_FIELD_NAME,
            new Constant(
                VE_TABLE_FIELD_NAME,
                null,
                "\n" +
                    "         48.5 48.4 51.4 48.9 48.2 46.0 46.0 46.0 51.6 52.3 52.4 51.8 50.8 49.9 48.9 48.0\n" +
                    "         45.6 48.9 49.2 51.9 49.0 46.0 46.0 46.0 49.7 50.0 49.5 48.3 47.1 46.0 44.9 43.8\n" +
                    "         46.7 47.0 49.0 54.7 49.8 46.0 46.0 46.0 53.2 53.3 52.5 51.3 50.0 48.8 47.7 46.5\n" +
                    "         50.0 48.0 50.0 62.9 60.1 47.1 46.7 44.5 45.6 52.7 54.1 54.5 51.9 46.9 45.6 48.3\n" +
                    "         54.3 51.0 51.3 71.5 68.3 51.3 50.5 48.0 48.3 49.6 54.6 56.8 55.6 50.7 49.4 51.8\n" +
                    "         68.9 70.8 72.0 73.9 72.0 65.6 59.1 53.7 55.3 56.2 53.0 58.0 56.8 55.8 55.5 55.8\n" +
                    "         68.9 70.8 72.0 73.9 72.0 65.4 58.8 57.9 59.5 59.3 55.6 59.5 58.4 58.3 59.1 59.5\n" +
                    "         68.9 70.8 72.0 73.9 72.0 65.6 59.1 58.8 60.1 62.8 60.7 62.2 62.0 61.7 61.8 61.6\n" +
                    "         68.9 70.8 72.0 73.9 72.0 68.1 64.1 63.4 62.0 63.8 65.1 67.5 67.1 66.5 65.2 63.9\n" +
                    "         64.3 70.8 72.0 73.9 72.0 68.4 64.8 64.3 63.1 64.6 68.4 72.0 72.1 71.4 69.1 66.8\n" +
                    "         64.8 70.8 72.0 73.9 72.0 68.8 65.6 65.1 64.2 65.4 70.1 74.7 77.2 76.7 73.2 69.3\n" +
                    "         65.2 70.8 72.0 73.9 72.0 69.2 66.3 66.0 65.2 66.1 69.4 77.1 80.5 80.3 77.9 72.2\n" +
                    "         66.1 70.8 72.0 73.9 72.0 69.9 67.7 67.7 67.4 67.7 70.4 78.5 82.8 82.7 80.6 77.8\n" +
                    "         66.6 69.7 70.9 72.2 71.0 68.3 68.5 68.5 68.5 68.5 70.8 77.4 80.2 79.8 78.3 77.4\n" +
                    "         67.0 68.6 69.7 70.6 70.1 68.9 69.2 69.4 69.5 69.2 71.1 72.8 73.8 73.2 71.9 68.7\n" +
                    "         67.5 67.5 68.6 68.9 69.1 69.5 69.9 70.2 70.6 70.0 71.2 70.6 70.0 69.3 68.4 67.0\n",
                "1",
                "16",
                "16"
            ),
            new Constant(
                VE_TABLE_FIELD_NAME,
                null,
                "\n" +
                    "           1.1   2.1   3.1   4.1   5.1   6.1   7.1   8.1   9.1  10.1  11.1  12.1  13.1  14.1  15.1  16.1  17.1  18.1  19.1  20.1  21.1  22.1  23.1  24.1\n" +
                    "          25.2  26.2  27.2  28.2  29.2  30.2  31.2  32.2  33.2  34.2  35.2  36.2  37.2  38.2  39.2  40.2  41.2  42.2  43.2  44.2  45.2  46.2  47.2  48.2\n" +
                    "          49.3  50.3  51.3  52.3  53.3  54.3  55.3  56.3  57.3  58.3  59.3  60.3  61.3  62.3  63.3  64.3  65.3  66.3  67.3  68.3  69.3  70.3  71.3  72.3\n" +
                    "          74.4  75.4  76.4  77.4  78.4  79.4  80.4  81.4  82.4  83.4  84.4  85.4  86.4  87.4  88.4  89.4  90.4  91.4  92.4  93.4  94.4  95.4  96.4  97.4\n" +
                    "          98.5  99.5 100.5 101.5 102.5 103.5 104.5 105.5 106.5 107.5 108.5 109.5 110.5 111.5 112.5 113.5 114.5 115.5 116.5 117.5 118.5 119.5 120.5 121.5\n" +
                    "         122.6 123.6 124.6 125.6 126.6 127.6 128.6 129.6 130.6 131.6 132.6 133.6 134.6 135.6 136.6 137.6 138.6 139.6 140.6 141.6 142.6 143.6 144.6 145.6\n" +
                    "         146.7 147.7 148.7 149.7 150.7 151.7 152.7 153.7 154.7 155.7 156.7 157.7 158.7 159.7 160.7 161.7 162.7 163.7 164.7 165.7 166.7 167.7 168.7 169.7\n" +
                    "         170.8 171.8 172.8 173.8 174.8 175.8 176.8 177.8 178.8 179.8 180.8 181.8 182.8 183.8 184.8 185.8 186.8 187.8 188.8 189.8 190.8 191.8 192.8 193.8\n" +
                    "         194.9 195.9 196.9 197.9 198.9 199.9 200.9 201.9 202.9 203.9 204.9 205.9 206.9 207.9 208.9 209.9 210.9 211.9 212.9 213.9 214.9 215.9 216.9 217.9\n" +
                    "         218.0 219.0 220.0 221.0 222.0 223.0 224.0 225.0 226.0 227.0 228.0 229.0 230.0 231.0 232.0 233.0 234.0 235.0 236.0 237.0 238.0 239.0 240.0 241.0\n" +
                    "         242.1 243.1 244.1 245.1 246.1 247.1 248.1 249.1 250.1 251.1 252.1 253.1 254.1 255.1 256.1 257.1 258.1 259.1 260.1 261.1 262.1 263.1 264.1 265.1\n" +
                    "         266.2 267.2 268.2 269.2 270.2 271.2 272.2 273.2 274.2 275.2 276.2 277.2 278.2 279.2 280.2 281.2 282.2 283.2 284.2 285.2 286.2 287.2 288.2 289.2\n" +
                    "         290.3 291.3 292.3 293.3 294.3 295.3 296.3 297.3 298.3 299.3 300.3 301.3 302.3 303.3 304.3 305.3 306.3 307.3 308.3 309.3 310.3 311.3 312.3 313.3\n" +
                    "         314.4 315.4 316.4 317.4 318.4 319.4 320.4 321.4 322.4 323.4 324.4 325.4 326.4 327.4 328.4 329.4 330.4 331.4 332.4 333.4 334.4 335.4 336.4 337.4\n" +
                    "         338.5 339.5 340.5 341.5 342.5 343.5 344.5 345.5 346.5 347.5 348.5 349.5 350.5 351.5 352.5 353.5 354.5 355.5 356.5 357.5 358.5 359.5 360.5 361.5\n" +
                    "         362.6 363.6 364.6 365.6 366.6 367.6 368.6 369.6 370.6 371.6 372.6 373.6 374.6 375.6 376.6 377.6 378.6 379.6 380.6 381.6 382.6 383.6 384.6 385.6\n",
                "1",
                "16",
                "24"
            ),
            new Constant(
                VE_TABLE_FIELD_NAME,
                "%",
                "\n" +
                    "         48.5 48.4 51.4 48.9 48.2 46.0 46.0 46.0 51.6 52.3 52.4 51.8 50.8 49.9 48.9 48.0 48.0 48.0 48.0 48.0 48.0 48.0 48.0 48.0\n" +
                    "         45.6 48.9 49.2 51.9 49.0 46.0 46.0 46.0 49.7 50.0 49.5 48.3 47.1 46.0 44.9 43.8 43.8 43.8 43.8 43.8 43.8 43.8 43.8 43.8\n" +
                    "         46.7 47.0 49.0 54.7 49.8 46.0 46.0 46.0 53.2 53.3 52.5 51.3 50.0 48.8 47.7 46.5 46.5 46.5 46.5 46.5 46.5 46.5 46.5 46.5\n" +
                    "         50.0 48.0 50.0 62.9 60.1 47.1 46.7 44.5 45.6 52.7 54.1 54.5 51.9 46.9 45.6 48.3 48.3 48.3 48.3 48.3 48.3 48.3 48.3 48.3\n" +
                    "         54.3 51.0 51.3 71.5 68.3 51.3 50.5 48.0 48.3 49.6 54.6 56.8 55.6 50.7 49.4 51.8 51.8 51.8 51.8 51.8 51.8 51.8 51.8 51.8\n" +
                    "         68.9 70.8 72.0 73.9 72.0 65.6 59.1 53.7 55.3 56.2 53.0 58.0 56.8 55.8 55.5 55.8 55.8 55.8 55.8 55.8 55.8 55.8 55.8 55.8\n" +
                    "         68.9 70.8 72.0 73.9 72.0 65.4 58.8 57.9 59.5 59.3 55.6 59.5 58.4 58.3 59.1 59.5 59.5 59.5 59.5 59.5 59.5 59.5 59.5 59.5\n" +
                    "         68.9 70.8 72.0 73.9 72.0 65.6 59.1 58.8 60.1 62.8 60.7 62.2 62.0 61.7 61.8 61.6 61.6 61.6 61.6 61.6 61.6 61.6 61.6 61.6\n" +
                    "         68.9 70.8 72.0 73.9 72.0 68.1 64.1 63.4 62.0 63.8 65.1 67.5 67.1 66.5 65.2 63.9 63.9 63.9 63.9 63.9 63.9 63.9 63.9 63.9\n" +
                    "         64.3 70.8 72.0 73.9 72.0 68.4 64.8 64.3 63.1 64.6 68.4 72.0 72.1 71.4 69.1 66.8 66.8 66.8 66.8 66.8 66.8 66.8 66.8 66.8\n" +
                    "         64.8 70.8 72.0 73.9 72.0 68.8 65.6 65.1 64.2 65.4 70.1 74.7 77.2 76.7 73.2 69.3 69.3 69.3 69.3 69.3 69.3 69.3 69.3 69.3\n" +
                    "         65.2 70.8 72.0 73.9 72.0 69.2 66.3 66.0 65.2 66.1 69.4 77.1 80.5 80.3 77.9 72.2 72.2 72.2 72.2 72.2 72.2 72.2 72.2 72.2\n" +
                    "         66.1 70.8 72.0 73.9 72.0 69.9 67.7 67.7 67.4 67.7 70.4 78.5 82.8 82.7 80.6 77.8 77.8 77.8 77.8 77.8 77.8 77.8 77.8 77.8\n" +
                    "         66.6 69.7 70.9 72.2 71.0 68.3 68.5 68.5 68.5 68.5 70.8 77.4 80.2 79.8 78.3 77.4 77.4 77.4 77.4 77.4 77.4 77.4 77.4 77.4\n" +
                    "         67.0 68.6 69.7 70.6 70.1 68.9 69.2 69.4 69.5 69.2 71.1 72.8 73.8 73.2 71.9 68.7 68.7 68.7 68.7 68.7 68.7 68.7 68.7 68.7\n" +
                    "         67.5 67.5 68.6 68.9 69.1 69.5 69.9 70.2 70.6 70.0 71.2 70.6 70.0 69.3 68.4 67.0 67.0 67.0 67.0 67.0 67.0 67.0 67.0 67.0\n",
                "1",
                "16",
                "24"
            )
        );

        testContext.checkPrevAndUpdatedIniFields(
            VE_RPM_BINS_FIELD_NAME,
            new ArrayIniField(
                VE_RPM_BINS_FIELD_NAME,
                32180,
                FieldType.UINT16,
                1,
                16,
                "RPM",
                1,
                "0",
                "18000",
                "0"
            ),
            new ArrayIniField(
                VE_RPM_BINS_FIELD_NAME,
                32436,
                FieldType.UINT16,
                1,
                24,
                "RPM",
                1,
                "0",
                "18000",
                "0"
            )
        );

        testContext.checkValueMigration(
            VE_RPM_BINS_FIELD_NAME,
            new Constant(
                VE_RPM_BINS_FIELD_NAME,
                null,
                "\n" +
                    "         800.0\n" +
                    "         1100.0\n" +
                    "         1300.0\n" +
                    "         1600.0\n" +
                    "         1900.0\n" +
                    "         2300.0\n" +
                    "         2700.0\n" +
                    "         3100.0\n" +
                    "         3500.0\n" +
                    "         4000.0\n" +
                    "         4500.0\n" +
                    "         5000.0\n" +
                    "         5500.0\n" +
                    "         6000.0\n" +
                    "         6800.0\n" +
                    "         8500.0\n",
                "0",
                "16",
                "1"
            ),
            new Constant(
                VE_RPM_BINS_FIELD_NAME,
                null,
                "\n" +
                    "         1.0\n" +
                    "         2.0\n" +
                    "         3.0\n" +
                    "         4.0\n" +
                    "         5.0\n" +
                    "         6.0\n" +
                    "         7.0\n" +
                    "         8.0\n" +
                    "         9.0\n" +
                    "         10.0\n" +
                    "         11.0\n" +
                    "         12.0\n" +
                    "         13.0\n" +
                    "         14.0\n" +
                    "         15.0\n" +
                    "         16.0\n" +
                    "         17.0\n" +
                    "         18.0\n" +
                    "         19.0\n" +
                    "         20.0\n" +
                    "         21.0\n" +
                    "         22.0\n" +
                    "         23.0\n" +
                    "         24.0\n",
                "0",
                "24",
                "1"
            ),
            new Constant(
                VE_RPM_BINS_FIELD_NAME,
                "RPM",
                "\n" +
                    "         800.0\n" +
                    "         1100.0\n" +
                    "         1300.0\n" +
                    "         1600.0\n" +
                    "         1900.0\n" +
                    "         2300.0\n" +
                    "         2700.0\n" +
                    "         3100.0\n" +
                    "         3500.0\n" +
                    "         4000.0\n" +
                    "         4500.0\n" +
                    "         5000.0\n" +
                    "         5500.0\n" +
                    "         6000.0\n" +
                    "         6800.0\n" +
                    "         8500.0\n" +
                    "         9300.0\n" +
                    "         10100.0\n" +
                    "         10900.0\n" +
                    "         11700.0\n" +
                    "         12500.0\n" +
                    "         13300.0\n" +
                    "         14100.0\n" +
                    "         14900.0\n",
                "0",
                "24",
                "1"
            )
        );
    }

    @Test
    void checkLambdaTableMigration() {
        testContext.checkPrevAndUpdatedIniFields(
            LAMBDA_TABLE_FIELD_NAME,
            new ArrayIniField(
                LAMBDA_TABLE_FIELD_NAME,
                32552,
                FieldType.UINT8,
                16,
                16,
                "afr",
                0.1,
                "0",
                "25",
                "1"
            ),
            new ArrayIniField(
                LAMBDA_TABLE_FIELD_NAME,
                33580,
                FieldType.UINT8,
                24,
                16,
                "afr",
                0.1,
                "0",
                "25",
                "1"
            )
        );

        testContext.checkValueMigration(
            LAMBDA_TABLE_FIELD_NAME,
            new Constant(
                LAMBDA_TABLE_FIELD_NAME,
                "afr",
                "\n" +
                    "         10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11.0 11.1 11.2 11.3 11.4 11.5\n" +
                    "         11.0 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 12.0 12.1 12.2 12.3 12.4 12.5\n" +
                    "         12.0 12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9 13.0 13.1 13.2 13.3 13.4 13.5\n" +
                    "         13.0 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 14.0 14.1 14.2 14.3 14.4 14.5\n" +
                    "         14.0 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 15.0 15.1 15.2 15.3 15.4 15.5\n" +
                    "         15.0 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16.0 16.1 16.2 16.3 16.4 16.5\n" +
                    "         16.0 16.1 16.2 16.3 16.4 16.5 16.6 16.7 16.8 16.9 17.0 17.1 17.2 17.3 17.4 17.5\n" +
                    "         17.0 17.1 17.2 17.3 17.4 17.5 17.6 17.7 17.8 17.9 18.0 18.1 18.2 18.3 18.4 18.5\n" +
                    "         18.0 18.1 18.2 18.3 18.4 18.5 18.6 18.7 18.8 18.9 19.0 19.1 19.2 19.3 19.4 19.5\n" +
                    "         19.0 19.1 19.2 19.3 19.4 19.5 19.6 19.7 19.8 19.9 20.0 20.1 20.2 20.3 20.4 20.5\n" +
                    "         20.0 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5\n" +
                    "         21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.9 22.0 22.1 22.2 22.3 22.4 22.5\n" +
                    "         22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5\n" +
                    "         23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5\n" +
                    "         24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5\n" +
                    "         25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5\n",
                "1",
                "16",
                "16"
            ),
            new Constant(
                LAMBDA_TABLE_FIELD_NAME,
                "afr",
                "\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n" +
                    "         0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n",
                "1",
                "16",
                "24"
            ),
            new Constant(
                LAMBDA_TABLE_FIELD_NAME,
                "afr",
                "\n" +
                    "         10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11.0 11.1 11.2 11.3 11.4 11.5 11.5 11.5 11.5 11.5 11.5 11.5 11.5 11.5\n" +
                    "         11.0 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 12.0 12.1 12.2 12.3 12.4 12.5 12.5 12.5 12.5 12.5 12.5 12.5 12.5 12.5\n" +
                    "         12.0 12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9 13.0 13.1 13.2 13.3 13.4 13.5 13.5 13.5 13.5 13.5 13.5 13.5 13.5 13.5\n" +
                    "         13.0 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 14.0 14.1 14.2 14.3 14.4 14.5 14.5 14.5 14.5 14.5 14.5 14.5 14.5 14.5\n" +
                    "         14.0 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 15.0 15.1 15.2 15.3 15.4 15.5 15.5 15.5 15.5 15.5 15.5 15.5 15.5 15.5\n" +
                    "         15.0 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16.0 16.1 16.2 16.3 16.4 16.5 16.5 16.5 16.5 16.5 16.5 16.5 16.5 16.5\n" +
                    "         16.0 16.1 16.2 16.3 16.4 16.5 16.6 16.7 16.8 16.9 17.0 17.1 17.2 17.3 17.4 17.5 17.5 17.5 17.5 17.5 17.5 17.5 17.5 17.5\n" +
                    "         17.0 17.1 17.2 17.3 17.4 17.5 17.6 17.7 17.8 17.9 18.0 18.1 18.2 18.3 18.4 18.5 18.5 18.5 18.5 18.5 18.5 18.5 18.5 18.5\n" +
                    "         18.0 18.1 18.2 18.3 18.4 18.5 18.6 18.7 18.8 18.9 19.0 19.1 19.2 19.3 19.4 19.5 19.5 19.5 19.5 19.5 19.5 19.5 19.5 19.5\n" +
                    "         19.0 19.1 19.2 19.3 19.4 19.5 19.6 19.7 19.8 19.9 20.0 20.1 20.2 20.3 20.4 20.5 20.5 20.5 20.5 20.5 20.5 20.5 20.5 20.5\n" +
                    "         20.0 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.5 21.5 21.5 21.5 21.5 21.5 21.5 21.5\n" +
                    "         21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.9 22.0 22.1 22.2 22.3 22.4 22.5 22.5 22.5 22.5 22.5 22.5 22.5 22.5 22.5\n" +
                    "         22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5\n" +
                    "         23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.5 24.5 24.5 24.5 24.5 24.5 24.5 24.5\n" +
                    "         24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5 25.5 25.5 25.5 25.5 25.5 25.5 25.5 25.5\n" +
                    "         25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5 26.5 26.5 26.5 26.5 26.5 26.5 26.5 26.5\n",
                "1",
                "16",
                "24"
            )
        );

        testContext.checkPrevAndUpdatedIniFields(
            LAMBDA_RPM_BINS_FIELD_NAME,
            new ArrayIniField(
                LAMBDA_RPM_BINS_FIELD_NAME,
                32840,
                FieldType.UINT16,
                1,
                16,
                "RPM",
                1,
                "0",
                "18000",
                "0"
            ),
            new ArrayIniField(
                LAMBDA_RPM_BINS_FIELD_NAME,
                33996,
                FieldType.UINT16,
                1,
                24,
                "RPM",
                1.0,
                "0",
                "18000",
                "0"
            )
        );

        testContext.checkValueMigration(
            LAMBDA_RPM_BINS_FIELD_NAME,
            new Constant(
                LAMBDA_RPM_BINS_FIELD_NAME,
                "RPM",
                "\n" +
                    "         800.0\n" +
                    "         1000.0\n" +
                    "         1300.0\n" +
                    "         1600.0\n" +
                    "         1900.0\n" +
                    "         2300.0\n" +
                    "         2700.0\n" +
                    "         3100.0\n" +
                    "         3500.0\n" +
                    "         4000.0\n" +
                    "         4500.0\n" +
                    "         5000.0\n" +
                    "         5500.0\n" +
                    "         6000.0\n" +
                    "         7250.0\n" +
                    "         8500.0\n",
                "0",
                "16",
                "1"
            ),
            new Constant(
                LAMBDA_RPM_BINS_FIELD_NAME,
                "RPM",
                "\n" +
                    "         650.0\n" +
                    "         800.0\n" +
                    "         950.0\n" +
                    "         1100.0\n" +
                    "         1250.0\n" +
                    "         1400.0\n" +
                    "         1550.0\n" +
                    "         1700.0\n" +
                    "         1850.0\n" +
                    "         2000.0\n" +
                    "         2150.0\n" +
                    "         2300.0\n" +
                    "         2450.0\n" +
                    "         2600.0\n" +
                    "         2750.0\n" +
                    "         2900.0\n" +
                    "         3050.0\n" +
                    "         3200.0\n" +
                    "         3350.0\n" +
                    "         3500.0\n" +
                    "         3650.0\n" +
                    "         3800.0\n" +
                    "         3950.0\n" +
                    "         7000.0\n",
                "0",
                "24",
                "1"
            ),
            new Constant(
                LAMBDA_RPM_BINS_FIELD_NAME,
                "RPM",
                "\n" +
                    "         800.0\n" +
                    "         1000.0\n" +
                    "         1300.0\n" +
                    "         1600.0\n" +
                    "         1900.0\n" +
                    "         2300.0\n" +
                    "         2700.0\n" +
                    "         3100.0\n" +
                    "         3500.0\n" +
                    "         4000.0\n" +
                    "         4500.0\n" +
                    "         5000.0\n" +
                    "         5500.0\n" +
                    "         6000.0\n" +
                    "         7250.0\n" +
                    "         8500.0\n" +
                    "         9000.0\n" +
                    "         9500.0\n" +
                    "         10000.0\n" +
                    "         10500.0\n" +
                    "         11000.0\n" +
                    "         11500.0\n" +
                    "         12000.0\n" +
                    "         12500.0\n",
                "0",
                "24",
                "1"
            )
        );
    }

    @Test
    void checkIgnitionTableMigration() {
        testContext.checkPrevAndUpdatedIniFields(
            IGNITION_TABLE_FIELD_NAME,
            new ArrayIniField(
                IGNITION_TABLE_FIELD_NAME,
                31128,
                FieldType.INT16,
                16,
                16,
                "deg",
                0.1,
                "-20",
                "90",
                "1"
            ),
            new ArrayIniField(
                IGNITION_TABLE_FIELD_NAME,
                31880,
                FieldType.INT16,
                24,
                16,
                "deg",
                0.1,
                "-20",
                "90",
                "1"
            )
        );

        testContext.checkValueMigration(
            IGNITION_TABLE_FIELD_NAME,
            new Constant(
                IGNITION_TABLE_FIELD_NAME,
                "deg",
                "\n" +
                    "         20.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11.0 11.1 11.2 11.3 11.4 21.5\n" +
                    "         21.0 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 12.0 12.1 12.2 12.3 12.4 22.5\n" +
                    "         22.0 12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9 13.0 13.1 13.2 13.3 13.4 23.5\n" +
                    "         23.0 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 14.0 14.1 14.2 14.3 14.4 24.5\n" +
                    "         24.0 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 15.0 15.1 15.2 15.3 15.4 25.5\n" +
                    "         25.0 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16.0 16.1 16.2 16.3 16.4 26.5\n" +
                    "         26.0 16.1 16.2 16.3 16.4 16.5 16.6 16.7 16.8 16.9 17.0 17.1 17.2 17.3 17.4 27.5\n" +
                    "         27.0 17.1 17.2 17.3 17.4 17.5 17.6 17.7 17.8 17.9 18.0 18.1 18.2 18.3 18.4 28.5\n" +
                    "         28.0 18.1 18.2 18.3 18.4 18.5 18.6 18.7 18.8 18.9 19.0 19.1 19.2 19.3 19.4 29.5\n" +
                    "         29.0 19.1 19.2 19.3 19.4 19.5 19.6 19.7 19.8 19.9 20.0 20.1 20.2 20.3 20.4 20.5\n" +
                    "         20.0 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5\n" +
                    "         21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.9 22.0 22.1 22.2 22.3 22.4 22.5\n" +
                    "         22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5\n" +
                    "         23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5\n" +
                    "         24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5\n" +
                    "         25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5\n",
                "1",
                "16",
                "16"
            ),
            new Constant(
                IGNITION_TABLE_FIELD_NAME,
                "deg",
                "\n" +
                    "         12.2 14.2 16.1 18.1 20.1 22.0 24.0 25.9 27.9 29.9 31.8 33.8 35.7 37.7 39.6 41.6 42.9 42.9 42.9 42.9 42.9 42.9 42.9 42.9\n" +
                    "         12.1 14.0 16.0 17.9 19.8 21.7 23.7 25.6 27.5 29.5 31.4 33.3 35.2 37.2 39.1 41.0 42.3 42.3 42.3 42.3 42.3 42.3 42.3 42.3\n" +
                    "         12.0 13.9 15.8 17.7 19.6 21.5 23.4 25.3 27.2 29.1 30.9 32.8 34.7 36.6 38.5 40.4 41.7 41.7 41.7 41.7 41.7 41.7 41.7 41.7\n" +
                    "         11.8 13.7 15.6 17.4 19.3 21.2 23.0 24.9 26.8 28.7 30.5 32.4 34.3 36.1 38.0 39.9 41.1 41.1 41.1 41.1 41.1 41.1 41.1 41.1\n" +
                    "         11.6 13.5 15.3 17.1 18.9 20.8 22.6 24.4 26.2 28.1 29.9 31.7 33.5 35.3 37.2 39.0 40.2 40.2 40.2 40.2 40.2 40.2 40.2 40.2\n" +
                    "         11.5 13.3 15.1 16.9 18.7 20.5 22.3 24.1 25.9 27.7 29.4 31.2 33.0 34.8 36.6 38.4 39.6 39.6 39.6 39.6 39.6 39.6 39.6 39.6\n" +
                    "         11.4 13.2 14.9 16.7 18.4 20.2 22.0 23.7 25.5 27.3 29.0 30.8 32.5 34.3 36.1 37.8 39.0 39.0 39.0 39.0 39.0 39.0 39.0 39.0\n" +
                    "         11.3 13.0 14.7 16.5 18.2 19.9 21.7 23.4 25.1 26.9 28.6 30.3 32.0 33.8 35.5 37.2 38.4 38.4 38.4 38.4 38.4 38.4 38.4 38.4\n" +
                    "         11.1 12.8 14.5 16.2 17.9 19.6 21.3 23.0 24.7 26.5 28.2 29.9 31.6 33.3 35.0 36.7 37.8 37.8 37.8 37.8 37.8 37.8 37.8 37.8\n" +
                    "         10.9 12.6 14.2 15.9 17.6 19.2 20.9 22.5 24.2 25.9 27.5 29.2 30.8 32.5 34.1 35.8 36.9 36.9 36.9 36.9 36.9 36.9 36.9 36.9\n" +
                    "         10.8 12.4 14.1 15.7 17.3 18.9 20.6 22.2 23.8 25.5 27.1 28.7 30.3 32.0 33.6 35.2 36.3 36.3 36.3 36.3 36.3 36.3 36.3 36.3\n" +
                    "         10.7 12.3 13.9 15.5 17.1 18.7 20.3 21.9 23.5 25.1 26.6 28.2 29.8 31.4 33.0 34.6 35.7 35.7 35.7 35.7 35.7 35.7 35.7 35.7\n" +
                    "         10.5 12.1 13.7 15.2 16.8 18.4 19.9 21.5 23.1 24.7 26.2 27.8 29.4 30.9 32.5 34.1 35.1 35.1 35.1 35.1 35.1 35.1 35.1 35.1\n" +
                    "         10.5 12.1 13.6 15.2 16.8 18.3 19.9 21.5 23.0 24.6 26.1 27.7 29.3 30.8 32.4 34.0 35.0 35.0 35.0 35.0 35.0 35.0 35.0 35.0\n" +
                    "         10.5 12.1 13.6 15.2 16.8 18.3 19.9 21.5 23.0 24.6 26.1 27.7 29.3 30.8 32.4 34.0 35.0 35.0 35.0 35.0 35.0 35.0 35.0 35.0\n" +
                    "         10.5 12.1 13.6 15.2 16.8 18.3 19.9 21.5 23.0 24.6 26.1 27.7 29.3 30.8 32.4 34.0 35.0 35.0 35.0 35.0 35.0 35.0 35.0 35.0\n",
                "1",
                "16",
                "24"
            ),
            new Constant(
                IGNITION_TABLE_FIELD_NAME,
                "deg",
                "\n" +
                    "         20.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11.0 11.1 11.2 11.3 11.4 21.5 21.5 21.5 21.5 21.5 21.5 21.5 21.5 21.5\n" +
                    "         21.0 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 12.0 12.1 12.2 12.3 12.4 22.5 22.5 22.5 22.5 22.5 22.5 22.5 22.5 22.5\n" +
                    "         22.0 12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9 13.0 13.1 13.2 13.3 13.4 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5\n" +
                    "         23.0 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 14.0 14.1 14.2 14.3 14.4 24.5 24.5 24.5 24.5 24.5 24.5 24.5 24.5 24.5\n" +
                    "         24.0 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 15.0 15.1 15.2 15.3 15.4 25.5 25.5 25.5 25.5 25.5 25.5 25.5 25.5 25.5\n" +
                    "         25.0 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16.0 16.1 16.2 16.3 16.4 26.5 26.5 26.5 26.5 26.5 26.5 26.5 26.5 26.5\n" +
                    "         26.0 16.1 16.2 16.3 16.4 16.5 16.6 16.7 16.8 16.9 17.0 17.1 17.2 17.3 17.4 27.5 27.5 27.5 27.5 27.5 27.5 27.5 27.5 27.5\n" +
                    "         27.0 17.1 17.2 17.3 17.4 17.5 17.6 17.7 17.8 17.9 18.0 18.1 18.2 18.3 18.4 28.5 28.5 28.5 28.5 28.5 28.5 28.5 28.5 28.5\n" +
                    "         28.0 18.1 18.2 18.3 18.4 18.5 18.6 18.7 18.8 18.9 19.0 19.1 19.2 19.3 19.4 29.5 29.5 29.5 29.5 29.5 29.5 29.5 29.5 29.5\n" +
                    "         29.0 19.1 19.2 19.3 19.4 19.5 19.6 19.7 19.8 19.9 20.0 20.1 20.2 20.3 20.4 20.5 20.5 20.5 20.5 20.5 20.5 20.5 20.5 20.5\n" +
                    "         20.0 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.5 21.5 21.5 21.5 21.5 21.5 21.5 21.5\n" +
                    "         21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.9 22.0 22.1 22.2 22.3 22.4 22.5 22.5 22.5 22.5 22.5 22.5 22.5 22.5 22.5\n" +
                    "         22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5\n" +
                    "         23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.5 24.5 24.5 24.5 24.5 24.5 24.5 24.5\n" +
                    "         24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5 25.5 25.5 25.5 25.5 25.5 25.5 25.5 25.5\n" +
                    "         25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5 26.5 26.5 26.5 26.5 26.5 26.5 26.5 26.5\n",
                "1",
                "16",
                "24"
            )
        );

        testContext.checkPrevAndUpdatedIniFields(
            IGNITION_RPM_BINS_FIELD_NAME,
            new ArrayIniField(
                IGNITION_RPM_BINS_FIELD_NAME,
                31672,
                FieldType.UINT16,
                1,
                16,
                "RPM",
                1,
                "0",
                "18000",
                "0"
            ),
            new ArrayIniField(
                IGNITION_RPM_BINS_FIELD_NAME,
                32680,
                FieldType.UINT16,
                1,
                24,
                "RPM",
                1.0,
                "0",
                "18000",
                "0"
            )
        );

        testContext.checkValueMigration(
            IGNITION_RPM_BINS_FIELD_NAME,
            new Constant(
                IGNITION_RPM_BINS_FIELD_NAME,
                "RPM",
                "\n" +
                    "         800.0\n" +
                    "         1000.0\n" +
                    "         1300.0\n" +
                    "         1600.0\n" +
                    "         1900.0\n" +
                    "         2300.0\n" +
                    "         2700.0\n" +
                    "         3100.0\n" +
                    "         3500.0\n" +
                    "         4000.0\n" +
                    "         4500.0\n" +
                    "         5000.0\n" +
                    "         5500.0\n" +
                    "         6000.0\n" +
                    "         6500.0\n" +
                    "         7000.0\n",
                "0",
                "16",
                "1"
            ),
            new Constant(
                IGNITION_RPM_BINS_FIELD_NAME,
                "RPM",
                "\n" +
                    "         650.0\n" +
                    "         800.0\n" +
                    "         950.0\n" +
                    "         1100.0\n" +
                    "         1250.0\n" +
                    "         1400.0\n" +
                    "         1550.0\n" +
                    "         1700.0\n" +
                    "         1850.0\n" +
                    "         2000.0\n" +
                    "         2150.0\n" +
                    "         2300.0\n" +
                    "         2450.0\n" +
                    "         2600.0\n" +
                    "         2750.0\n" +
                    "         2900.0\n" +
                    "         3050.0\n" +
                    "         3200.0\n" +
                    "         3350.0\n" +
                    "         3500.0\n" +
                    "         3650.0\n" +
                    "         3800.0\n" +
                    "         3950.0\n" +
                    "         7000.0\n",
                "0",
                "24",
                "1"
            ),
            new Constant(
                IGNITION_RPM_BINS_FIELD_NAME,
                "RPM",
                "\n" +
                    "         800.0\n" +
                    "         1000.0\n" +
                    "         1300.0\n" +
                    "         1600.0\n" +
                    "         1900.0\n" +
                    "         2300.0\n" +
                    "         2700.0\n" +
                    "         3100.0\n" +
                    "         3500.0\n" +
                    "         4000.0\n" +
                    "         4500.0\n" +
                    "         5000.0\n" +
                    "         5500.0\n" +
                    "         6000.0\n" +
                    "         6500.0\n" +
                    "         7000.0\n" +
                    "         7500.0\n" +
                    "         8000.0\n" +
                    "         8500.0\n" +
                    "         9000.0\n" +
                    "         9500.0\n" +
                    "         10000.0\n" +
                    "         10500.0\n" +
                    "         11000.0\n",
                "0",
                "24",
                "1"
            )
        );
    }

    @Test
    void checkInjactionPhaseMigration() {
        testContext.checkPrevAndUpdatedIniFields(
            INJECTION_PHASE_FIELD_NAME,
            new ArrayIniField(
                INJECTION_PHASE_FIELD_NAME,
                31128,
                FieldType.INT16,
                16,
                16,
                "deg",
                1.0,
                "-720",
                "720",
                "0"
            ),
            new ArrayIniField(
                INJECTION_PHASE_FIELD_NAME,
                30204,
                FieldType.INT16,
                24,
                16,
                "deg",
                1.0,
                "-720",
                "720",
                "0"
            )
        );

        testContext.checkValueMigration(
            INJECTION_PHASE_FIELD_NAME,
            new Constant(
                INJECTION_PHASE_FIELD_NAME,
                "deg",
                "\n" +
                    "         20.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11.0 11.1 11.2 11.3 11.4 21.5\n" +
                    "         21.0 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 12.0 12.1 12.2 12.3 12.4 22.5\n" +
                    "         22.0 12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9 13.0 13.1 13.2 13.3 13.4 23.5\n" +
                    "         23.0 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 14.0 14.1 14.2 14.3 14.4 24.5\n" +
                    "         24.0 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 15.0 15.1 15.2 15.3 15.4 25.5\n" +
                    "         25.0 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16.0 16.1 16.2 16.3 16.4 26.5\n" +
                    "         26.0 16.1 16.2 16.3 16.4 16.5 16.6 16.7 16.8 16.9 17.0 17.1 17.2 17.3 17.4 27.5\n" +
                    "         27.0 17.1 17.2 17.3 17.4 17.5 17.6 17.7 17.8 17.9 18.0 18.1 18.2 18.3 18.4 28.5\n" +
                    "         28.0 18.1 18.2 18.3 18.4 18.5 18.6 18.7 18.8 18.9 19.0 19.1 19.2 19.3 19.4 29.5\n" +
                    "         29.0 19.1 19.2 19.3 19.4 19.5 19.6 19.7 19.8 19.9 20.0 20.1 20.2 20.3 20.4 20.5\n" +
                    "         20.0 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5\n" +
                    "         21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.9 22.0 22.1 22.2 22.3 22.4 22.5\n" +
                    "         22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5\n" +
                    "         23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5\n" +
                    "         24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5\n" +
                    "         25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5\n",
                "1",
                "16",
                "16"
            ),
            new Constant(
                INJECTION_PHASE_FIELD_NAME,
                "deg",
                "\n" +
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"+
                    "        -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0 -400.0\n"
                ,
                "0",
                "16",
                "24"
            ),
            new Constant(
                INJECTION_PHASE_FIELD_NAME,
                "deg",
                "\n" +
                    "         20.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11.0 11.1 11.2 11.3 11.4 21.5 21.5 21.5 21.5 21.5 21.5 21.5 21.5 21.5\n" +
                    "         21.0 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 12.0 12.1 12.2 12.3 12.4 22.5 22.5 22.5 22.5 22.5 22.5 22.5 22.5 22.5\n" +
                    "         22.0 12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9 13.0 13.1 13.2 13.3 13.4 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5\n" +
                    "         23.0 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 14.0 14.1 14.2 14.3 14.4 24.5 24.5 24.5 24.5 24.5 24.5 24.5 24.5 24.5\n" +
                    "         24.0 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 15.0 15.1 15.2 15.3 15.4 25.5 25.5 25.5 25.5 25.5 25.5 25.5 25.5 25.5\n" +
                    "         25.0 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16.0 16.1 16.2 16.3 16.4 26.5 26.5 26.5 26.5 26.5 26.5 26.5 26.5 26.5\n" +
                    "         26.0 16.1 16.2 16.3 16.4 16.5 16.6 16.7 16.8 16.9 17.0 17.1 17.2 17.3 17.4 27.5 27.5 27.5 27.5 27.5 27.5 27.5 27.5 27.5\n" +
                    "         27.0 17.1 17.2 17.3 17.4 17.5 17.6 17.7 17.8 17.9 18.0 18.1 18.2 18.3 18.4 28.5 28.5 28.5 28.5 28.5 28.5 28.5 28.5 28.5\n" +
                    "         28.0 18.1 18.2 18.3 18.4 18.5 18.6 18.7 18.8 18.9 19.0 19.1 19.2 19.3 19.4 29.5 29.5 29.5 29.5 29.5 29.5 29.5 29.5 29.5\n" +
                    "         29.0 19.1 19.2 19.3 19.4 19.5 19.6 19.7 19.8 19.9 20.0 20.1 20.2 20.3 20.4 20.5 20.5 20.5 20.5 20.5 20.5 20.5 20.5 20.5\n" +
                    "         20.0 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.5 21.5 21.5 21.5 21.5 21.5 21.5 21.5\n" +
                    "         21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.9 22.0 22.1 22.2 22.3 22.4 22.5 22.5 22.5 22.5 22.5 22.5 22.5 22.5 22.5\n" +
                    "         22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5 23.5\n" +
                    "         23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.5 24.5 24.5 24.5 24.5 24.5 24.5 24.5\n" +
                    "         24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5 25.5 25.5 25.5 25.5 25.5 25.5 25.5 25.5\n" +
                    "         25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5 26.5 26.5 26.5 26.5 26.5 26.5 26.5 26.5\n",
                "0",
                "16",
                "24"
            )
        );

        testContext.checkPrevAndUpdatedIniFields(
            INJECTION_PHASE_RPM_BINS_FIELD_NAME,
            new ArrayIniField(
                INJECTION_PHASE_RPM_BINS_FIELD_NAME,
                30268,
                FieldType.UINT16,
                1,
                16,
                "RPM",
                1,
                "0",
                "18000",
                "0"
            ),
            new ArrayIniField(
                INJECTION_PHASE_RPM_BINS_FIELD_NAME,
                31004,
                FieldType.UINT16,
                1,
                24,
                "RPM",
                1.0,
                "0",
                "18000",
                "0"
            )
        );

        testContext.checkValueMigration(
            INJECTION_PHASE_RPM_BINS_FIELD_NAME,
            new Constant(
                INJECTION_PHASE_RPM_BINS_FIELD_NAME,
                "RPM",
                "\n" +
                    "         800.0\n" +
                    "         1000.0\n" +
                    "         1300.0\n" +
                    "         1600.0\n" +
                    "         1900.0\n" +
                    "         2300.0\n" +
                    "         2700.0\n" +
                    "         3100.0\n" +
                    "         3500.0\n" +
                    "         4000.0\n" +
                    "         4500.0\n" +
                    "         5000.0\n" +
                    "         5500.0\n" +
                    "         6000.0\n" +
                    "         6500.0\n" +
                    "         7000.0\n",
                "0",
                "16",
                "1"
            ),
            new Constant(
                INJECTION_PHASE_RPM_BINS_FIELD_NAME,
                "RPM",
                "\n" +
                    "         650.0\n" +
                    "         800.0\n" +
                    "         1100.0\n" +
                    "         1400.0\n" +
                    "         1700.0\n" +
                    "         2000.0\n" +
                    "         2300.0\n" +
                    "         2600.0\n" +
                    "         2900.0\n" +
                    "         3200.0\n" +
                    "         3500.0\n" +
                    "         3800.0\n" +
                    "         4100.0\n" +
                    "         4400.0\n" +
                    "         4700.0\n" +
                    "         7000.0\n" +
                    "         7300.0\n" +
                    "         7600.0\n" +
                    "         7900.0\n" +
                    "         8200.0\n" +
                    "         8500.0\n" +
                    "         8800.0\n" +
                    "         9100.0\n" +
                    "         9400.0\n",
                "0",
                "24",
                "1"
            ),
            new Constant(
                INJECTION_PHASE_RPM_BINS_FIELD_NAME,
                "RPM",
                "\n" +
                    "         800.0\n" +
                    "         1000.0\n" +
                    "         1300.0\n" +
                    "         1600.0\n" +
                    "         1900.0\n" +
                    "         2300.0\n" +
                    "         2700.0\n" +
                    "         3100.0\n" +
                    "         3500.0\n" +
                    "         4000.0\n" +
                    "         4500.0\n" +
                    "         5000.0\n" +
                    "         5500.0\n" +
                    "         6000.0\n" +
                    "         6500.0\n" +
                    "         7000.0\n" +
                    "         7500.0\n" +
                    "         8000.0\n" +
                    "         8500.0\n" +
                    "         9000.0\n" +
                    "         9500.0\n" +
                    "         10000.0\n" +
                    "         10500.0\n" +
                    "         11000.0\n",
                "0",
                "24",
                "1"
            )
        );
    }
}
